package cn.dgut.training.service.impl;

import cn.dgut.training.entity.Address;
import cn.dgut.training.entity.Region;
import cn.dgut.training.mapper.RegionMapper;
import cn.dgut.training.service.IRegionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.print.attribute.Attribute;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService {


    @Resource
    private RegionMapper regionMapper;



    public List<Region> listRegion(Integer pid){

        QueryWrapper<Region> queryWrapper = new QueryWrapper();
        //获取条件查询构造器
        queryWrapper.eq("pid", pid);

        List<Region> regionList = regionMapper.selectList(queryWrapper);

        return regionList;
    }

    public Region getByName(Long id,String name) {

        QueryWrapper<Region> queryWrapper = new QueryWrapper();
        //获取条件查询构造器
        queryWrapper.eq("pid", id);
        queryWrapper.eq("name", name);


        Region region=regionMapper.selectOne(queryWrapper);
        return  region;
    }
}
